<html>
<head>
<script>
	function isDefined( variable){
		return (typeof(window[variable]) == "undefined")?  false: true;
	}
	
	var ccURL = "http://www.conquerclub.com";
	var requestTimeout = 1000 * 10;  // 10 seconds
	var gmailRe = /https?\:\/\/www.conquerclub.com\/(?!a\/)/;


	function initialize()
	{
		window.setTimeout(startRequest, 0);
	}

	function scheduleRequest() {
		window.setTimeout(startRequest, pollInterval);
	}

	function startRequest() {
		getUpdates();
		scheduleRequest();
	}

	function getUpdates(){
		var pollInterval = 1000 * localStorage["refresh"];
	
		var xmlhttp=new window.XMLHttpRequest();
		xmlhttp.open("GET",localStorage["rsslink"],false);
		xmlhttp.send(null);
		var xmlDoc = xmlhttp.responseXML.documentElement;
		var x = xmlDoc.getElementsByTagName("title");
		var message = "";

		for(i=1;i<x.length;i++){
			if(x[i].childNodes[0].nodeValue.indexOf('READY', 0) != -1){
				message = "!";
			}
		}
		
		chrome.browserAction.setBadgeText({text:message});
	}

	function scheduleRequest() {
		window.setTimeout(startRequest, pollInterval);
	}

	chrome.extension.onRequest.addListener(
		function(request, sender, sendResponse) {
			if(!isDefined(localStorage["refresh"])){
				localStorage["refresh"] = 60;
			}
		
			if (request.rsslink != ""){
				localStorage["rsslink"] = request.rsslink;
			}else
				sendResponse({}); // snub them.
	});
</script>
</script> 
</head> 
<body onload="initialize()"> 
</body> 
</html> 